// 进行多语言支持配置
import Vue from "vue"; // 引入Vue
import VueI18n from "vue-i18n";
import elementEnLocale from "element-ui/lib/locale/lang/en"; // element-ui lang
import elementZhLocale from "element-ui/lib/locale/lang/zh-CN";// element-ui lang
import tdesignEnLocale from "tdesign-vue/es/locale/en_US";
import tdesignZhLocale from "tdesign-vue/es/locale/zh_CN";
import enLocale from "./en";
import zhLocale from "./zh";

// 引入国际化的插件包
Vue.use(VueI18n); // 全局注册国际化包

// 设置语言
const messages = {
  en: {
    ...enLocale,
    ...elementEnLocale,
    ...tdesignEnLocale
  },
  zh: {
    ...zhLocale,
    ...elementZhLocale,
    ...tdesignZhLocale
  }
};

const i18n = new VueI18n({
  // set locale
  // options: en | zh | es
  locale: localStorage.getItem("language") || "zh",
  // set locale messages
  messages
});

export default i18n;